package com.wxlsoft.config.deploy;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collection;

import com.wxlsoft.config.ConfigNodeContext;
import com.wxlsoft.config.model.ConfigFileResource;

import cn.hutool.core.io.resource.Resource;

public class AbstractDeployHandler {

	protected Collection<ConfigFileResource> resources() throws IOException {
		Collection<ConfigFileResource> resource = ConfigNodeContext.getConfigFileResource();
		return resource;
	}
	
	protected String getContent(Resource resource) throws IOException {
		return resource.readStr(Charset.defaultCharset());
	}
	
	/**
	 * 返回文件扩展名
	 * @param filename
	 * @return
	 */
	protected String getFileExt(String filename) {
        int separatorIndex = filename.lastIndexOf(".");
        if (separatorIndex < 0) {
            return "";
        }
        return filename.substring(separatorIndex + 1).toLowerCase();
	}
	
}
